#coding=utf-8
import epics

cache = {}

def cagetDouble(data):
  tmp = epics.caget(data)
  if not tmp:
    return None
  else:
    return "%.3f" % tmp

def cagetDouble2(data):
  tmp = epics.caget(data[0])
  if not tmp:
    return [data[1], None,  data[2]]
  else:
    return [data[1], "%.3f" % tmp,  data[2]]

def cagetBool(data):
  tmp = epics.caget(data[0])
  if data[0] not in cache.keys(): cache[data[0]] = None
  if tmp: cache[data[0]] = tmp
  return [data[1], cache[data[0]], data[2]]

